﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Data;

namespace ComboBoxBindings
{
    public class EducationGradeConverter : IValueConverter
    {
        #region IValueConverter Members

        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            EducationGrade getValue = (EducationGrade)value;

            switch (getValue)
            {
                case EducationGrade.EducationGrade1:
                    return "EducationGrade1";
                case EducationGrade.EducationGrade2:
                    return "EducationGrade2";
                case EducationGrade.EducationGrade3:
                    return "EducationGrade3";
                default:
                    return "EducationGrade1";
            }

        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            string s = value as string;

            switch (s)
            {
                case "EducationGrade1":
                    return EducationGrade.EducationGrade1;
                case "EducationGrade2":
                    return EducationGrade.EducationGrade2;
                case "EducationGrade3":
                    return EducationGrade.EducationGrade3;
                default:
                    return EducationGrade.EducationGrade1;
            }
        }

        #endregion
    }
}
